added samples
[windows-sources.git] / sdk / samples / all in on code / Visual Studio 2008 / VBCustomIEContextMenu / OpenImageMenuExt.vb
bloba6fe7c1cb013c5643a046f4dfa65c25353f0f0f5
1 '*************************** Module Header ******************************'
2 ' Module Name: OpenImageMenuExt.vb
3 ' Project: VBCustomIEContextMenu
4 ' Copyright (c) Microsoft Corporation.
5 '
6 ' The class OpenImageMenuExt is used to add/remove the menu in registry when this
7 ' assembly is registered/unregistered.
8 '
9 '
10 ' This source is subject to the Microsoft Public License.
11 ' See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
12 ' All other rights reserved.
14 ' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
15 ' EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
16 ' WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
17 '*************************************************************************'
19 Imports System.IO
20 Imports System.Reflection
21 Imports System.Runtime.InteropServices
22 Imports Microsoft.Win32
24 Public Class OpenImageMenuExt
25 Private Const IEMenuExtRegistryKey As String = _
26 "Software\Microsoft\Internet Explorer\MenuExt"
28 Public Shared Sub RegisterMenuExt()
30 ' If the key exists, CreateSubKey will open it.
31 Dim ieMenuExtKey As RegistryKey = _
32 Registry.CurrentUser.CreateSubKey( _
33 IEMenuExtRegistryKey & "\Open image in new Tab")
36 ' Get the path of Resource\OpenImage.htm.
37 Dim fileIofo As New FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location)
38 Dim path As String = fileIofo.Directory.FullName & "\Resource\OpenImage.htm"
40 ' Set the default value of the key to the path.
41 ieMenuExtKey.SetValue(String.Empty, path)
43 ' Set the value of Name.
44 ieMenuExtKey.SetValue("Name", "Open_Image")
46 ' Set the value of Contexts to indicate which contexts your entry should
47 ' appear in the standard context menu by using a bit mask consisting of
48 ' the logical OR of the following values:
49 ' Default 0x1
50 ' Images 0x2
51 ' Controls 0x4
52 ' Tables 0x8
53 ' Text selection 0x10
54 ' Anchor 0x20
55 ieMenuExtKey.SetValue("Contexts", &H2)
57 ieMenuExtKey.Close()
58 End Sub
60 Public Shared Sub UnRegisterMenuExt()
61 Dim ieMenuExtskey As RegistryKey = _
62 Registry.CurrentUser.OpenSubKey(IEMenuExtRegistryKey, True)
64 If ieMenuExtskey IsNot Nothing Then
65 ieMenuExtskey.DeleteSubKey("Open image in new Tab", False)
66 End If
68 ieMenuExtskey.Close()
69 End Sub
70 End Class